2019年7月8日
Jerry
5765
2019年7月8日
新装的Linux系统(比如说Ubuntu),默认的python版本都是python2,那么如何修改默认的python版本呢?
当前默认情况下 输入 python --version 会显示默认的版本,一般都是2.7的版本。
root@1234567:/home# python
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
输入python3才会显示3的版本:
root@1234567:/home# python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
此时,我们只需要执行下面两条命令,改一下python 的优先级即可~
// update-alternatives --install /usr/bin/python python /usr/bin/python2 100
// update-alternatives --install /usr/bin/python python /usr/bin/python3 150
root@1234:/home# update-alternatives --install /usr/bin/python python /usr/bin/python2 100
update-alternatives: using /usr/bin/python2 to provide /usr/bin/python (python) in auto mode
root@1234:/home# update-alternatives --install /usr/bin/python python /usr/bin/python3 150
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode
root@1234:/home# python
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
原创文章,转载请注明出处:
https://jerrycoding.com/article/python-priority
《备忘录》
0
微信
支付宝